package com.bt.lms.service.impl;

import com.bt.lms.entity.ClassInfo;
import com.bt.lms.entity.StuBasicInfo;
import com.bt.lms.entity.page.Page;
import com.bt.lms.dao.servise.ClassInfoDao;
import com.bt.lms.dao.servise.impl.ClassInfoDaoImpl;
import com.bt.lms.service.ClassInfoService;

import java.util.List;

/**
 * 班级信息服务类
 *
 * @author 李鹏
 */
public class ClassInfoServiceImpl implements ClassInfoService {

    @Override
    public List<ClassInfo> randomAverageDivide(List<ClassInfo> classInfos, Long enrollmentPlanId) throws Exception {

        //随机分班班级信息表
        //sql语句
        String sql = "insert into class_info (class_id,class_name,stu_no,divide_id) values (?,?,?,?)";

        ClassInfoDao classInfoDao = new ClassInfoDaoImpl();
        classInfoDao.insert(sql, classInfos);

        //分班数量表
        //sql语句
        String sql1 = "insert into divide_class_info (class_number,enp_id) values(?,?)";
        classInfoDao.insertClassInfo(sql1, classInfos, enrollmentPlanId);

        return classInfos;
    }

    @Override
    public List<ClassInfo> handDivide(List<ClassInfo> classInfos, Long enrollmentPlanId) throws Exception {

        //手动分班班级信息表
        //sql语句
        String sql = "insert into hand_class_info (class_id,class_name,stu_no,divide_id) values (?,?,?,?)";

        ClassInfoDao classInfoDao = new ClassInfoDaoImpl();
        classInfoDao.insertHandClassInfo(sql, classInfos);

        //分班数量表
        //sql语句
        String sql1 = "insert into hand_divide_info (class_number,enp_id) values(?,?)";
        classInfoDao.insertHandDivideInfo(sql1, classInfos, enrollmentPlanId);

        return classInfos;
    }

    @Override
    public boolean add(ClassInfo classInfo, List<StuBasicInfo> studentBasicInfos) {
        return false;
    }


    @Override
    public boolean delete(ClassInfo classInfo, List<StuBasicInfo> studentBasicInfos) {
        return false;
    }

    @Override
    public List<ClassInfo> previewDivideResult(List<ClassInfo> classInfos, Long enrollmentPlanId) throws Exception {

        String sql = "select * from class_info where id = ?";
        ClassInfoDao classInfoDao = new ClassInfoDaoImpl();
        classInfoDao.previewResult(sql, classInfos, enrollmentPlanId);

        return classInfos;
    }

    @Override
    public boolean adjust(StuBasicInfo studentBasicInfo, ClassInfo classInfo) {

        return true;
    }

    @Override
    public Page<StuBasicInfo> pagingConditionQuery(Page<ClassInfo> page) {

        return null;
    }

    @Override
    public StuBasicInfo checkStu(Long id) {

        return null;
    }
}
